// 继承
function Animal(age) {
  this.age = age;
}
Animal.prototype.eat = function () {
  console.log('i eat');
};
Animal.prototype.run = function () {
  console.log('i run');
};
Animal.prototype.sleep = function () {
  console.log('i sleep');
};

function Dog(name, age) {
  Animal.call(this, age);
  this.name = name;
}
Dog.prototype = Object.create(Animal.prototype);

Dog.prototype.constructor = Dog;

Dog.prototype.greet = function () {
  console.log('wangwangwang');
};
Dog.prototype.eat = function () {
  console.log('dog eats');
};
const xiaoliu = new Dog('xiaoliu', 3);
xiaoliu.eat();
xiaoliu.greet();
const xiaoai = new Animal(5);
xiaoai.eat();
xiaoai.greet();
